Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-36760][sql-client] Supports to deploy script via sql client #25754

Merged
merged 6 commits into from
Jan 7, 2025

Conversation

fsk119
Copy link
Member

@fsk119 fsk119 commented Dec 6, 2024

What is the purpose of the change

Support to deploy script via SQL Client.

Brief change log

  • Support to deploy script
  • Support to deploy script with remote jar
  • Relax the limitation that script exists in local

Verifying this change

This change added tests and can be verified as follows:

  • Added integration tests to check deploy script with fake target
  • Added E2E case to fetch resources from the remote jar

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Dec 6, 2024

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

@davidradl
Copy link
Contributor

Reviewed by Chi on 12/12/24 Group to test and/or review outside of the meeting. @tomncooper one you might want to look at.

Copy link
Contributor

@hackergin hackergin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fsk119 Thanks for your contribution, only some minor comments.

@fsk119 fsk119 force-pushed the client branch 5 times, most recently from 5d1f6dc to 36cd7bc Compare January 4, 2025 15:25
Copy link
Contributor

@hackergin hackergin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fsk119 Thanks for the update, LGTM.

String scheme = StringUtils.lowerCase(uri.getScheme());
String clusterId;
// local files
if (scheme == null || scheme.equals("file")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better if we could support shipping local files to the remote? That said, I think the current implementation is also fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we just read the sql script file if the file is in local fs. It's not an easy work to ship files in the k8s deployment. It requires users to configure a remote oss env.

Copy link
Contributor

@lsyldliu lsyldliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fsk119 Thanks for your contribution, LGTM overall, just left some minor comments.

@@ -35,16 +36,16 @@ public class CliOptions {

private final boolean isPrintHelp;
private final String sessionId;
private final URL initFile;
private final URL sqlFile;
private final URI initFile;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just a little curious that why we change it to URI type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because URL requires to qualify referred resources. For example, if users uses the hdfs://path/to/object as the input, the sql client needs to validate whether the protocol is valid. However, in the client side, users may not configure hdfs parameters.

@@ -213,6 +213,8 @@ public AttributedString build() {

public static final String MESSAGE_EXECUTE_STATEMENT = "Execute statement succeeded.";

public static final String MESSAGE_DEPLOY_SCRIPT = "Deploy script in application mode: ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Deploy SQL script in application mode: "?
BTW, the content after the colon is an SQL script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to align the style with other prompt message(we only upper case the first word), you can take a look at the line above.

The content after the colon is the cluster id, which helps users to find the deployment

@@ -331,6 +334,19 @@ public List<String> completeStatement(String statement, int position) {
.getCandidates();
}

@Override
public String deployScript(@Nullable String script, @Nullable URI uri) {
return getResponse(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would better that we check the two parameters can not be null simutaneously.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I delay the check in the server side.

@@ -78,6 +80,12 @@ private YarnClusterDescriptor getClusterDescriptor(Configuration configuration)
final YarnConfiguration yarnConfiguration =
Utils.getYarnAndHadoopConfiguration(configuration);

if (System.getenv().get("IN_TESTS") != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aim of this change is?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Integration test setup, the Yarn containers created by YarnMiniCluster does not have the Yarn site XML and KRB5 configuration files. We are adding these files as container local resources for the container applications (JM/TMs) to have proper secure cluster setup

+ ") WITH (\n"
+ " 'connector' = 'blackhole'\n"
+ ");\n"
+ "INSERT INTO sink VALUES (1), (2), (3);");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add test to cover the udf jar?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because code freeze time is coming, I will add a test in another PR.

throw new SqlClientException(
"Sql Client doesn't support to run init files when deploying script into cluster.");
}
boolean success = cli.executeInitialization(options.getInitFile());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confuse that what content are init file? is it sql query, sql ddl or config option? After see the line 147 and line 153 error message, I guess it is a sql query.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take a look at th doc.

Script file that used to init the session context. If ge error in execution, the sql client will exit. Notice it's not allowed to add query or insert into the init file.

Copy link
Contributor

@lsyldliu lsyldliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fsk119 fsk119 merged commit 4a8b8c0 into apache:master Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants